<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // es5设置默认参数
        function fn(x, y) {
            y = y || "大闸蟹"
            console.log(x, y)
        }
        fn("孙悟空")//孙悟空 大闸蟹
        fn("孙悟空", "猪八戒")//孙悟空 猪八戒


        // es6设置默认参数
        function fnn(x, y = "唐僧", z = "沙和尚") {
            console.log(x, y, z);
        }
        fnn("孙悟空", "猪八戒")//孙悟空 猪八戒 沙和尚
    </script>
</body>
</html>